Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix span in proc macro #4265

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

Sindbad-Walter
Copy link
Contributor

Follow up of rust-lang/rust#130277 that was initially handled in #4259. The rust team pointed out that the macro was not correctly setting the span and proposed a fix, being the use of Span::mixed_site instead of coping directly the span of the field.

The #[allow(unused_qualifications)] is still here in the wrap_in_dummy_mod as it is hard to make sure the lint is correctly done in every proc macro.

@weiznich weiznich requested a review from a team September 16, 2024 12:47
@Sindbad-Walter Sindbad-Walter marked this pull request as draft September 16, 2024 12:55
@Sindbad-Walter Sindbad-Walter marked this pull request as ready for review September 17, 2024 12:36
Copy link
Member

@weiznich weiznich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for opening this PR 🙏

The changes itself look fine to me, although I personally would prefer to address all potential other locations that somewhat use a span at once.

(Also as minor note: Would it be possible to squash all those commits?)

@@ -93,7 +93,8 @@ where
}

pub fn wrap_in_dummy_mod(item: TokenStream) -> TokenStream {
// #[allow(unused_qualifications)] can be removed if https://github.com/rust-lang/rust/issues/130277 gets done
// allow(unused_qualifications) is here as it hard to unsure the span is correctly set. Should stay until it is
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather prefer auditing the derive crate to ensure all usages of spans are encoded correctly. Yes that's a bit of work but it should fix all these issues at once.
The alternative is to remove this allow and start searching again if something pops up in some code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants